﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudentManage.Data;

namespace StudentManage.Web.Admin.Management.indexImg
{
    public partial class IndexImgList : SecurityPage
    {
        public override string PrivCode()
        {
            return "7f5f3d8c75f14949";
        }

        int i = 0;
        public string GetXN()
        {
            if (i == 0)
                i = (this.AspNetPager1.PageSize) * (this.AspNetPager1.CurrentPageIndex - 1);

            i += 1;
            return i.ToString();
        }

        private void RepDataBind()
        {
            List<ImgList> list = ImgList.All().OrderByDescending(p=>p.AddTime).ToList();
            this.Rep_List.DataSource = list;
            this.Rep_List.DataBind();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            this.RepDataBind();
        }

        protected void Rep_DataList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                int imgID = Convert.ToInt32(e.CommandArgument);
                ImgList.Delete("id=@0",imgID);
                this.RepDataBind();
            }
        }

        protected void Btn_Add_Click(object sender, EventArgs e)
        {
            Response.Redirect("IndexImgEdit.aspx");
        }


    }
}